<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>酒店预约</title>
    <!-- 引入公用部分 -->
    <script th:replace="common/head::static"></script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend><span th:text="${hotelByID.getHotelName()}"></span> 预约信息</legend>
</fieldset>
<img th:src="${hotelByID.getHotelPic()}" style="width: 410px; height: 200px; margin: 0 20px 20px 20px;" /><br>
<div class="layui-collapse">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title"><span th:text="${hotelByID.getHotelName()}"></span>简介</h2>
        <div class="layui-colla-content layui-show">
            <p th:text="${hotelByID.getHotelDesc()}"></p>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">地址</h2>
        <div class="layui-colla-content">
            <p th:text="${hotelByID.getHotelAddress()}"></p>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">联系方式</h2>
        <div class="layui-colla-content">
            <p th:text="${hotelByID.getHotelPhone()}"></p>
        </div>
    </div>
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">价格</h2>
        <div class="layui-colla-content">
            <p th:text="${hotelByID.getHotelPrice()}"></p>
        </div>
    </div>
</div>

<form class="layui-form" lay-filter="reservation" id="sub_form" style="margin-top: 20px;">
    <div class="layui-form-item">
        <label class="layui-form-label">酒店ID</label>
        <div class="layui-input-inline">
            <input type="text" id="hotelId" name="hotelId" autocomplete="off" class="layui-input" readonly >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="reservationName" lay-verify="title" autocomplete="off" placeholder="请输入您的姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="tel" name="reservationPhone" lay-verify="required|phone" autocomplete="off" placeholder="请输入您的手机号" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit1">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    layui.use(['element', 'layer', 'form'], function() {
        const element = layui.element;
        const layer = layui.layer;
        const $ = layui.jquery;
        const form = layui.form;

        //监听提交
        form.on('submit(submit1)', function (data) {
            $.ajax({
                url: ctx + '/travel/hotel/reservation/save',
                method: 'post',
                data:$("#sub_form").serialize(),
                success: (res) => {
                    layer.msg('预约成功');
                    setTimeout(function(){  // 设置定时器
                        const index = parent.layer.getFrameIndex(window.name);  // 获取当前弹窗的Id
                        parent.layer.close(index);  // 关闭
                    }, 2000);
                }
            })
            return false;
        });
    });
</script>
</body>
</html>